File:Cubic set z^3+A*z+c with two cycles of length 3 and 105.png

From testwiki
Jump to navigation Jump to search
    Original file (2,000 × 2,000 pixels, file size: 558 KB, MIME type: image/png)

    This file is from Wikimedia Commons and may be used by other projects. The description on its file description page there is shown below.

    Summary

    Description
    English: Cubic Julia set z^3+A*z+c with two cycles of length 3 ( gray) and 105 ( black). c=(-5947392-3850240*i) * 2^-25 A=(-17343094-31007487*i) * 2^-25. Location by Marc Meidlinger: "Almost failed" [1]
    Date
    Source Own work
    Author Adam majewski

    Licensing

    I, the copyright holder of this work, hereby publish it under the following license:
    w:en:Creative Commons
    attribution share alike
    This file is licensed under the Creative Commons Attribution-Share Alike 4.0 International license.
    You are free:
    • to share – to copy, distribute and transmit the work
    • to remix – to adapt the work
    Under the following conditions:
    • attribution – You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
    • share alike – If you remix, transform, or build upon the material, you must distribute your contributions under the same or compatible license as the original.

    Algorithm

    Here are 3 Fatou components. Each component has its own test ( and radius : ER, AR3, AR105)


    unsigned char ComputeColor_Fatou (complex double z, int IterMax)
    {
    
      int i;			// number of iteration
      for (i = 0; i < IterMax; ++i)
        {
          z = f(z);
          if (IsEscaping(z)) // escaping = exterior
    	{
    	  uExterior += 1;
    	  return iColorOfExterior;
    	}			 
    
    	
    	if (IsAttracting3(z)) // 
    	{
    	  uInterior3 += 1;
    	  return iColorOfInterior3;
    	}			 
    
    
    	if (IsAttracting105(z)) //
    	{
    	  uInterior105 += 1;
    	  return iColorOfInterior105;
    	}			 
        }
    
      //
      uUnknown += 1;
      return iColorOfUnknown;
    }
    

    cycles

    coefficients read from input file almost_failed.txt
    	degree 3 coefficient = ( 1.000000 +0.000000*i) 
    	degree 1 coefficient = ( -17343094 -31007487*i) / 2^25
    	degree 0 coefficient = ( -5947392 -3850240*i) / 2^25
    
    Input polynomial p(z)=(1+0i)*z^3+(-0.51686447858810424805-0.9240951240062713623i)*z^1+(-0.17724609375-0.11474609375i)
    
    2 critical points found
    
    	cp#0: -0.51245892538596249377,-0.30054282669590931532 . It's critical orbit is bounded and enters cycle #0 length=105 and it's stability = |multiplier|=0.28704 =attractive 
    cycle = {
    -0.24732793789495804981,0.29215263953094150473 ; 0.26876710406969839262,-0.0085171236418623563758 ; -0.3046767904944813754,-0.36055537020136457782 ; -0.26241535545808958307,0.29962592335603582816 ; 0.28787510018461370809,0.0078838929604866936351 ; -0.29494991315089091888,-0.38288540074102683786 ; -0.27455873309559225559,0.31191915190416169557 ; 0.31234799441805982667,0.017944373517944256502 ; -0.2919340307234095655,-0.40741391215611333365 ; -0.28235422026374618065,0.3290654079280695421 ; 0.34199350012506646301,0.019164449919817083678 ; -0.29667802201690768316,-0.43396868516467318466 ; -0.28342600463717920745,0.35085345796581834943 ; 0.37536866371159016698,0.0071858850187334066817 ; -0.31178847180608326717,-0.46229943654508381945 ; -0.27370494394472238975,0.37630203167158604582 ; 0.40772920474884866149,-0.025028103409567903359 ; -0.34409922814958437964,-0.49105709722591744937 ; -0.2449944738941836897,0.40102658228395615669 ; 0.42346616544766646495,-0.087906711439687451604 ; -0.41123452015233963319,-0.50724519093837194816 ; -0.18555276198412737343,0.40061722316252434961 ; 0.37181981448693979253,-0.17325968219142176552 ; -0.51161578092029436071,-0.43544956783496435726 ; -0.15809057050791477939,0.3237346187548343357 ; 0.24938141179809353298,-0.14563807260629968443 ; -0.4410850929751095606,-0.29400621596562687143 ; -0.19238863541649192657,0.29863158302528308718 ; 0.24250792287362227251,-0.084784862368257829512 ; -0.37190697423471780203,-0.309373342281155983 ; -0.21556349411693073725,0.29007338496181866994 ; 0.24662389567201831175,-0.049444009034894792487 ; -0.3372164738703821163,-0.32599535518510897036 ; -0.23503715928209542585,0.28880228310276029324 ; 0.25694407721793599553,-0.023046653588218862785 ; -0.31479457215798800629,-0.3448272629740875006 ; -0.25209517751790111451,0.29287235772481545748 ; 0.27254351923198216756,-0.0024445319540177257167 ; -0.30013349931606225773,-0.36588346388981141111 ; -0.26672768173431404826,0.30182257792420147391 ; 0.29344693016079059777,0.012657480463004577853 ; -0.29209367512707334891,-0.3891933522549606006 ; -0.27811441375559786682,0.31567172351627070803 ; 0.31984174502015799701,0.020891698446799555899 ; -0.29095440306864639446,-0.41470600265690205077 ; -0.28460453460461010433,0.33447169082783989591 ; 0.35140389365293778212,0.019237607102409959303 ; -0.29809405043374392896,-0.44230042353392406973 ; -0.28344007123985115459,0.35794909570135724497 ; 0.38621138880840610863,0.0025762164015241673098 ; -0.31688506654918935368,-0.47182092741151032689 ; -0.2696571589714125694,0.38485242207865261177 ; 0.41798013130114330949,-0.037521187970981417781 ; -0.35669945222245802441,-0.5012189884266159412 ; -0.23260870002965125525,0.40853985295680106393 ; 0.42439558633283758216,-0.11282617213027651415 ; -0.44063198174895995551,-0.50813980847646678107 ; -0.16329862573530923298,0.39030796337721151978 ; 0.33811514589344227044,-0.19381421358626163554 ; -0.53055744312808894581,-0.38621214111975221694 ; -0.17185025068141757121,0.30662016434653083241 ; 0.23831820717466317694,-0.11608257686068315651 ; -0.40379436623070885659,-0.29319052218167213075 ; -0.20118237053461970887,0.29172688754129455502 ; 0.23954321827980773474,-0.069022639922116713063 ; -0.35451938248878084314,-0.31198438514458648463 ; -0.22334763687303690882,0.2868496242954856057 ; 0.24726213893104953545,-0.037289013031137935306 ; -0.32541988506948532622,-0.33075400541779792496 ; -0.24235656540970954009,0.28803306487651270107 ; 0.26027404781921337218,-0.012801394511054969838 ; -0.30609853229264927243,-0.35124698678255716899 ; -0.25900635641491209782,0.29426841916134605093 ; 0.2784669582250638431,0.0062440397203482600474 ; -0.29384485773949253762,-0.37385105724090489376 ; -0.2730067007934079415,0.30543570183403107032 ; 0.30217227794736428725,0.019469614970230836315 ; -0.28818929179203861546,-0.39871935525962554081 ; -0.2832343880221637189,0.32169475666996583119 ; 0.33163637741350115995,0.024846157766341692152 ; -0.28983687276644753972,-0.42586914619178423136 ; -0.2876327929002780448,0.34311899843429255474 ; 0.36628864210255529521,0.018473728533294292431 ; -0.30072723525105027331,-0.45535064597357716165 ; -0.28273285588115038003,0.36938191097603756408 ; 0.40336219146392526813,-0.0062111966138009844229 ; -0.32588864780611004335,-0.48731224634183589739 ; -0.26156969938358271,0.39874134969146712848 ; 0.4332932280993916363,-0.060679693179994331764 ; -0.38071219062333577776,-0.51774021779493506479 ; -0.20793645379329273037,0.41832597847804342539 ; 0.41697573567503387615,-0.15775430867425729864 ; -0.4971780737983561016,-0.49689343919691547624 ; -0.13408028198229832162,0.35572947363411777655 ; 0.26927362987571457076,-0.20053692237335982163 ; -0.51470125367609298461,-0.29548729312417754134 ; -0.18580704247024834586,0.30457435706928459584 ; 0.24554126587236080326,-0.097174772283400157047 ; -0.38610846805622028866,-0.30808192777216636404 ; -0.20999645581128842386,0.29274656858186481889 ; 0.24654919780813883134,-0.058359174620379622445 ; -0.34614026729578128982,-0.32286081274663902541 ; -0.22992066652498396873,0.28960159742890478896 ; 0.25490644957189917408,-0.030322853277308270403 ; -0.32115939206444649168,-0.34051410523394409768 ; }
    
    	cp#1: 0.51245892538596249377,0.3005428266959092598 . It's critical orbit is bounded and enters cycle #1 length=3 and it's stability = |multiplier|=0.85666 =attractive 
    cycle = {
    -0.15708836166441453308,-0.53313337552781914219 ; -0.45864684434588676165,0.41804133400602072612 ; 0.59009996754766946836,0.283773874530894199 ; }
    

    c src code

    /*
    
      Adam Majewski
      adammaj1 aaattt o2 dot pl  // o like oxygen not 0 like zero 
      
      
      
    "Almost failed"
    
    Cubic set z^3+A*z+c with two cycles of length 3 and 105 at L20 in about 20h computed.
    
    c=(-5947392-3850240*i) * 2^-25
    A=(-17343094-31007487*i) * 2^-25
    
    -----------
    
     gcc l.c -lm -Wall -march=native -fopenmp
    a@zalman:~/Dokumenty/almost$ ./a.out
    setup start
     end of setup 
    compute Fatou image 
    File 15000_100000.pgm saved . Comment = name = iWidth+IterMax	 f(z) = z^6+A*z+c where A= 15000.0000000000000000 ; -0.9240951240062714 	 c =-0.1772460937500000 ; -0.1147460937500000 
     allways free memory (deallocate )  to avoid memory leaks 
    Numerical approximation of Julia set for fc(z)= z^3+A*z+c 
    parameter c = ( -0.1772460937500000 ; -0.1147460937500000 ) 
    parameter A = ( -0.5168644785881042 ; -0.9240951240062714 ) 
    Image Width = 3.000000 in world coordinate
    PixelWidth = 0.0002000133342223 
    Maximal number of iterations = iterMax = 100000 
    ratio of image  = 1.000000 ; it should be 1.000 ...
    gcc version: 9.3.0
    __STDC__ = 1
    __STDC_VERSION__ = 201710
    c dialect = C18
    a@zalman:~/Dokumenty/almost$ convert 15000_100000.pgm -resize 2000x2000 15.png
    
      
      ==============================================
      
      
      Structure of a program or how to analyze the program 
      
      
      ============== Image X ========================
      
      DrawImageOfX -> DrawPointOfX -> ComputeColorOfX 
      
      first 2 functions are identical for every X
      check only last function =  ComputeColorOfX
      which computes color of one pixel !
      
      
    
       
      ==========================================
    
      
      ---------------------------------
      indent d.c 
      default is gnu style 
      -------------------
    
    
    
      c console progam 
      
    	export  OMP_DISPLAY_ENV="TRUE"	
      	gcc d.c -lm -Wall -march=native -fopenmp
      	time ./a.out > b.txt
    
    
      gcc l.c -lm -Wall -march=native -fopenmp
    
    
      time ./a.out
    
      time ./a.out >i.txt
      time ./a.out >e.txt
      
      
      
      
      
      
      convert -limit memory 1000mb -limit disk 1gb dd30010000_20_3_0.90.pgm -resize 2000x2000 10.png
    
      
      =======================
      # gnuplot "i.plt"
    set terminal svg enhanced background rgb 'white'
    set xlabel "re(z)"
    set ylabel "DLD"
    set title "Relation between z and DLD in the interior of Julia set for c = -1"
    set output "interior.svg"
    plot "i.txt" with lines
    
      ----------------------
      d0 - db  = 5.0000000000000000 - 4.5389870050569598 = 0.4610129949430402
     allways free memory (deallocate )  to avoid memory leaks 
    Numerical approximation of Julia set for fc(z)= z^2 + c 
    parameter c = ( -1.0000000000000000 ; 0.0000000000000000 ) 
    Image Width = 4.000000 in world coordinate
    PixelWidth = 0.004004 
    Maximal number of iterations = iterMax = 1000 
    ratio of image  = 1.000000 ; it should be 1.000 ...
    gcc version: 7.5.0
      
      
    */
    
    #include <stdio.h>
    #include <stdlib.h>		// malloc
    #include <string.h>		// strcat
    #include <math.h>		// M_PI; needs -lm also
    #include <complex.h>
    #include <omp.h>		// OpenMP
    #include <limits.h>		// Maximum value for an unsigned long long int
    
    
    
    // https://sourceforge.net/p/predef/wiki/Standards/
    
    #if defined(__STDC__)
    #define PREDEF_STANDARD_C_1989
    #if defined(__STDC_VERSION__)
    #if (__STDC_VERSION__ >= 199409L)
    #define PREDEF_STANDARD_C_1994
    #endif
    #if (__STDC_VERSION__ >= 199901L)
    #define PREDEF_STANDARD_C_1999
    #endif
    #endif
    #endif
    
    
    
    
    /* --------------------------------- global variables and consts ------------------------------------------------------------ */
    
    
    
    // virtual 2D array and integer ( screen) coordinate
    // Indexes of array starts from 0 not 1 
    //unsigned int ix, iy; // var
    static unsigned int ixMin = 0;	// Indexes of array starts from 0 not 1
    static unsigned int ixMax;	//
    static unsigned int iWidth;	// horizontal dimension of array
    
    static unsigned int iyMin = 0;	// Indexes of array starts from 0 not 1
    static unsigned int iyMax;	//
    
    static unsigned int iHeight = 15000;	//  
    // The size of array has to be a positive constant integer 
    static unsigned long long int iSize;	// = iWidth*iHeight; 
    
    // memmory 1D array 
    unsigned char *data;
    //unsigned char *edge;
    //unsigned char *edge2;
    
    // unsigned int i; // var = index of 1D array
    //static unsigned int iMin = 0; // Indexes of array starts from 0 not 1
    static unsigned int iMax;	// = i2Dsize-1  = 
    // The size of array has to be a positive constant integer 
    // unsigned int i1Dsize ; // = i2Dsize  = (iMax -iMin + 1) =  ;  1D array with the same size as 2D array
    
    
    
    // zoom to part of period
    static const double ZxMin = -1.5; //0.6;	//-0.05;
    static const double ZxMax = 1.5;	//0.75;
    static const double ZyMin = -1.5;	//-0.1;
    static const double ZyMax = 1.5;	//0.7;
    static double PixelWidth;	// =(ZxMax-ZxMin)/ixMax;
    static double PixelHeight;	// =(ZyMax-ZyMin)/iyMax;
    static double ratio;
    
    
    // complex numbers of parametr plane 
    //https://fractalforums.org/fractal-mathematics-and-new-theories/28/julia-sets-true-shape-and-escape-time/2725/msg22791#msg22791
    /*
    
    c=(-5947392-3850240*i) * 2^-25
    A=(-17343094-31007487*i) * 2^-25
    
    */
    double complex c = - 0.11474609375*I -0.17724609375;
    	// parameter of function fc(z)=z^6 +A*x+ c  = (15728640-19136512*i) * (2^-25)
                       
    
    double complex  A=  - 0.9240951240062714 *I - 0.5168644785881043;
    
    complex double f(complex double z) {
    
    	return  z*z*z +A*z+ c;		// complex iteration z^6+A*z+c
    	}
    
    
    
    
    
    /*
    ER = pow(10,ERe);
       AR = pow(10,-ARe);
     */
     
    int ARe_3 = 2; 
    double AR_3 ; //= 1e-15;			// increase ARe until black ( unknown) points disapear 
    double AR2_3;
    
    int ARe_105 = 2; 
    double AR_105 ; //= 1e-15;			// increase ARe until black ( unknown) points disapear 
    double AR2_105;
    
    
    
    double ER;			//= 1e60;
    double ER2;			//ER2 = ER*ER
    double AR2;			//AR2 = AR*AR
    
    complex double z3  = 0.5900999663884065+0.2837738661170331*I;
    complex double z105 = -0.5147160557032144-0.2946889400739363*I; //
    //-0.3861355806430767 -0.3080847982463079*I;
    
    
    /*
    [-0.1570883645161246,-0.5331333747802431],
    [-0.4586468403362385,0.4180413342397985],
    [0.5900999663884065,0.2837738661170331]]
    
    
    period 105 
    */
    
    int IterMax = 100000;
    
    
    
    
    /* colors = shades of gray from 0 to 255 */
    unsigned char iColorOfExterior = 250;
    unsigned char iColorOfInterior3 = 100;
    unsigned char iColorOfInterior105 = 30;
    unsigned char iColorOfBoundary = 0;
    unsigned char iColorOfUnknown = 20;
    
    // pixel counters
    unsigned long long int uUnknown = 0;
    unsigned long long int uInterior3 = 0;
    unsigned long long int uInterior105 = 0;
    unsigned long long int uExterior = 0;
    
    
    
    /* ------------------------------------------ functions -------------------------------------------------------------*/
    
    
    
    
    
    //------------------complex numbers -----------------------------------------------------
    
    
    
    
    
    // from screen to world coordinate ; linear mapping
    // uses global cons
    double
    GiveZx (int ix)
    {
      return (ZxMin + ix * PixelWidth);
    }
    
    // uses globaal cons
    double
    GiveZy (int iy)
    {
      return (ZyMax - iy * PixelHeight);
    }				// reverse y axis
    
    
    complex double
    GiveZ (int ix, int iy)
    {
      double Zx = GiveZx (ix);
      double Zy = GiveZy (iy);
    
      return Zx + Zy * I;
    
    
    }
    
    
    
    
    double cabs2(complex double z){
    
    	return creal(z)*creal(z)+cimag(z)*cimag(z);
    
    
    }
    
    
    
    
    // ****************** DYNAMICS = trap tests ( target sets) ****************************
    
    
    /* -----------  array functions = drawing -------------- */
    
    /* gives position of 2D point (ix,iy) in 1D array  ; uses also global variable iWidth */
    unsigned int
    Give_i (unsigned int ix, unsigned int iy)
    {
      return ix + iy * iWidth;
    }
    
    
    
    unsigned int Give_i_from_z(complex double z){
    
    	unsigned int ix = (creal(z)-ZxMin)/PixelWidth;
    	unsigned int iy = (ZyMax - cimag(z))/PixelHeight;
    	return Give_i(ix,iy);
    }
    
    // ***********************************************************************************************
    // ********************** edge detection usung Sobel filter ***************************************
    // ***************************************************************************************************
    
    // from Source to Destination
    int
    ComputeBoundaries (unsigned char S[], unsigned char D[])
    {
    
      unsigned int iX, iY;		/* indices of 2D virtual array (image) = integer coordinate */
      unsigned int i;		/* index of 1D array  */
      /* sobel filter */
      unsigned char G, Gh, Gv;
      // boundaries are in D  array ( global var )
    
      // clear D array
      memset (D, iColorOfExterior, iSize * sizeof (*D));	// for heap-allocated arrays, where N is the number of elements = FillArrayWithColor(D , iColorOfExterior);
    
      // printf(" find boundaries in S array using  Sobel filter\n");   
    #pragma omp parallel for schedule(dynamic) private(i,iY,iX,Gv,Gh,G) shared(iyMax,ixMax)
      for (iY = 1; iY < iyMax - 1; ++iY)
        {
          for (iX = 1; iX < ixMax - 1; ++iX)
    	{
    	  Gv =
    	    S[Give_i (iX - 1, iY + 1)] + 2 * S[Give_i (iX, iY + 1)] +
    	    S[Give_i (iX - 1, iY + 1)] - S[Give_i (iX - 1, iY - 1)] -
    	    2 * S[Give_i (iX - 1, iY)] - S[Give_i (iX + 1, iY - 1)];
    	  Gh =
    	    S[Give_i (iX + 1, iY + 1)] + 2 * S[Give_i (iX + 1, iY)] +
    	    S[Give_i (iX - 1, iY - 1)] - S[Give_i (iX + 1, iY - 1)] -
    	    2 * S[Give_i (iX - 1, iY)] - S[Give_i (iX - 1, iY - 1)];
    	  G = sqrt (Gh * Gh + Gv * Gv);
    	  i = Give_i (iX, iY);	/* compute index of 1D array from indices of 2D array */
    	  if (G == 0)
    	    {
    	      D[i] = 255;
    	    }			/* background */
    	  else
    	    {
    	      D[i] = 0;
    	    }			/* boundary */
    	}
        }
    
    
    
      return 0;
    }
    
    
    
    // copy from Source to Destination
    int
    CopyBoundaries (unsigned char S[], unsigned char D[])
    {
    
      unsigned int iX, iY;		/* indices of 2D virtual array (image) = integer coordinate */
      unsigned int i;		/* index of 1D array  */
    
    
      //printf("copy boundaries from S array to D array \n");
      for (iY = 1; iY < iyMax - 1; ++iY)
        for (iX = 1; iX < ixMax - 1; ++iX)
          {
    	i = Give_i (iX, iY);
    	if (S[i] == 0)
    	  D[i] = 0;
          }
    
    
    
      return 0;
    }
    
    
    
    int IsEscaping(complex double z){
    
    	if (cabs2 (z) > ER2) return 1;
    	return 0;
    }
    
    
    int IsAttracting3(complex double z){
    
    	if (cabs2 (z - z3) < AR2_3) return 1;
    	return 0;
    }
    
    
    
    
    
    int IsAttracting105(complex double z){
    
    	if (cabs2 (z - z105) < AR2_105) return 1;
    	return 0;
    }
    
    
    
    
    
    
    // find basin and it's color using simple test ( bailout ) for escaping to infinity 
    
    unsigned char
    ComputeColor_Fatou (complex double z, int IterMax)
    {
    
      int i;			// number of iteration
      for (i = 0; i < IterMax; ++i)
        {
    
    
    
    
          z = f(z);
          if (IsEscaping(z)) // escaping = exterior
    	{
    	  uExterior += 1;
    	  return iColorOfExterior;
    	}			 
    
    	
    	if (IsAttracting3(z)) // 
    	{
    	  uInterior3 += 1;
    	  return iColorOfInterior3;
    	}			 
    
    
    	if (IsAttracting105(z)) //
    	{
    	  uInterior105 += 1;
    	  return iColorOfInterior105;
    	}			 
    
    
    
    
    
        }
    
      //
      uUnknown += 1;
      return iColorOfUnknown;
    
    
    }
    
    
    
    
    
    // plots raster point (ix,iy) 
    int
    DrawFatouPoint (unsigned char A[], int ix, int iy, int IterMax)
    {
      int i;			/* index of 1D array */
      unsigned char iColor = 0;
      complex double z;
    
    
      i = Give_i (ix, iy);		/* compute index of 1D array from indices of 2D array */
      z = GiveZ (ix, iy);
      iColor = ComputeColor_Fatou (z, IterMax);
      A[i] = iColor;		// interior
    
      return 0;
    }
    
    
    
    
    // fill array 
    // uses global var :  ...
    // scanning complex plane 
    int
    DrawFatouImage (unsigned char A[], int IterMax)
    {
      unsigned int ix, iy;		// pixel coordinate 
    
      fprintf (stderr, "compute Fatou image \n");
      // for all pixels of image 
    #pragma omp parallel for schedule(dynamic) private(ix,iy) shared(A, ixMax , iyMax, uUnknown, uInterior3, uInterior105, uExterior)
      for (iy = iyMin; iy <= iyMax; ++iy)
        {
          fprintf (stderr," %d from %d \r", iy, iyMax);	//info 
          for (ix = ixMin; ix <= ixMax; ++ix)
    	DrawFatouPoint (A, ix, iy, IterMax);	//  
        }
    
      return 0;
    }
    
    
    //=========
    
    
    
    
    
    // plots raster point (ix,iy) 
    int MarkTrapPoint (unsigned char A[], int ix, int iy)
    {
      int i;			/* index of 1D array */
      
      complex double z;
    
    
      i = Give_i (ix, iy);		/* compute index of 1D array from indices of 2D array */
      z = GiveZ (ix, iy);
      if (IsAttracting3(z))   A[i] = 255 - A[i];		// inversion
      
      if (IsAttracting105(z))   A[i] = 255 - A[i];		// inversion
    
      return 0;
    }
    
    
    
    // fill array 
    // uses global var :  ...
    // scanning complex plane 
    int MarkTraps (unsigned char A[])
    {
      unsigned int ix, iy;		// pixel coordinate 
    
      fprintf (stderr, "Mark traps\n");
      // for all pixels of image 
    #pragma omp parallel for schedule(dynamic) private(ix,iy) shared(A, ixMax , iyMax, uUnknown, uInterior3, uInterior105, uExterior)
      for (iy = iyMin; iy <= iyMax; ++iy)
        {
          fprintf (stderr," %d from %d \r", iy, iyMax);	//info 
          for (ix = ixMin; ix <= ixMax; ++ix)
    	MarkTrapPoint (A, ix, iy);	//  
        }
    
      return 0;
    }
    
    
    //======================================================================================
    
    
    
    int IsInside (int x, int y, int xcenter, int ycenter, int r){
    
    	
    	double dx = x- xcenter;
    	double dy = y - ycenter;
    	double d = sqrt(dx*dx+dy*dy);
    	if (d<r) 
    		return 1;
    	return 0;
    	  
    
    } 
    
    int PlotPoint(complex double z, unsigned char A[]){
    
    	
    	unsigned int ix_seed = (creal(z)-ZxMin)/PixelWidth;
    	unsigned int iy_seed = (ZyMax - cimag(z))/PixelHeight;
    	unsigned int i;
    	
    	
    	 /* mark seed point by big pixel */
      	int iSide =3.0*iWidth/2000.0 ; /* half of width or height of big pixel */
      	int iY;
      	int iX;
      	for(iY=iy_seed-iSide;iY<=iy_seed+iSide;++iY){ 
        		for(iX=ix_seed-iSide;iX<=ix_seed+iSide;++iX){ 
        			if (IsInside(iX, iY, ix_seed, iy_seed, iSide)) {
          			i= Give_i(iX,iY); /* index of _data array */
          			A[i]= 255;}}}
    	
    	
    	return 0;
    	
    }
    
    
    // fill array 
    // uses global var :  ...
    // scanning complex plane 
    int MarkAttractors (unsigned char A[])
    {
      
    	int iter;
    	
    	complex double z;
      	fprintf (stderr, "mark attractors \n");
      
      	// period 3 cycle
      	z = z3;
      	PlotPoint(z, A);
    	for (iter = 0; iter < 3; ++iter)
        		{ z  = f(z);
        		  PlotPoint(z, A);	
        		 
          				}
          	// period 105			
          	z = z105;
      	PlotPoint(z, A);
    	for (iter = 0; iter < 105; ++iter)
        		{ z  = f(z);
        		  PlotPoint(z, A);	
        		 
          				}
    
      return 0;
    }
    
    
    //======================================================================================
    
    
    
    
    
    
    
    
    
    
    // *******************************************************************************************
    // ********************************** save A array to pgm file ****************************
    // *********************************************************************************************
    
    int
    SaveArray2PGMFile (unsigned char B[], int ia, int ib,  int ic, int id,  int ie, char *comment)
    {
    
      FILE *fp;
      const unsigned int MaxColorComponentValue = 255;	/* color component is coded from 0 to 255 ;  it is 8 bit color file */
      char name[100];		/* name of file */
      snprintf (name, sizeof name, "%d_%d_%d_%d_%d", ia, ib, ic ,id,ie);	/*  */
      char *filename = strcat (name, ".pgm");
      char long_comment[200];
      sprintf (long_comment, "%s\t f(z) = z^6+A*z+c where A= %.16f ; %.16f \t c =%.16f ; %.16f", comment, creal(A),cimag(A), creal(c), cimag(c));
    
    
    
    
    
      // save image array to the pgm file 
      fp = fopen (filename, "wb");	// create new file,give it a name and open it in binary mode 
      fprintf (fp, "P5\n # %s\n %u %u\n %u\n", long_comment, iWidth, iHeight, MaxColorComponentValue);	// write header to the file
      fwrite (B, iSize, 1, fp);	// write array with image data bytes to the file in one step 
      fclose (fp);
    
      // info 
      printf ("File %s saved ", filename);
      if (long_comment == NULL || strlen (long_comment) == 0)
        printf ("\n");
      else
        printf (". Comment = %s \n", long_comment);
    
      return 0;
    }
    
    
    
    
    int
    PrintCInfo ()
    {
    
      printf ("gcc version: %d.%d.%d\n", __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__);	// https://stackoverflow.com/questions/20389193/how-do-i-check-my-gcc-c-compiler-version-for-my-eclipse
      // OpenMP version is displayed in the console : export  OMP_DISPLAY_ENV="TRUE"
    
      printf ("__STDC__ = %d\n", __STDC__);
      printf ("__STDC_VERSION__ = %ld\n", __STDC_VERSION__);
      printf ("c dialect = ");
      switch (__STDC_VERSION__)
        {				// the format YYYYMM 
        case 199409L:
          printf ("C94\n");
          break;
        case 199901L:
          printf ("C99\n");
          break;
        case 201112L:
          printf ("C11\n");
          break;
        case 201710L:
          printf ("C18\n");
          break;
          //default : /* Optional */
    
        }
    
      return 0;
    }
    
    
    int
    PrintProgramInfo ()
    {
    
    
      // display info messages
      printf ("Numerical approximation of Julia set for fc(z)= z^3+A*z+c \n");
      //printf ("iPeriodParent = %d \n", iPeriodParent);
      //printf ("iPeriodOfChild  = %d \n", iPeriodChild);
      printf ("parameter c = ( %.16f ; %.16f ) \n", creal (c), cimag (c));
      printf ("parameter A = ( %.16f ; %.16f ) \n", creal (A), cimag (A));
    
      printf ("Image Width = %f in world coordinate\n", ZxMax - ZxMin);
      printf ("PixelWidth = %.16f \n", PixelWidth);
      printf ("AR_3 = %.16f \n", AR_3);
      printf ("ER = %.16f \n", ER);
       
    
    
      //printf("pixel counters\n");
      //printf ("uUnknown = %llu\n", uUnknown);
      //printf ("uExterior = %llu\n", uExterior);
      //printf ("uInterior = %llu\n", uInterior);
      //printf ("Sum of pixels  = %llu\n", uInterior+uExterior + uUnknown);
      //printf ("all pixels of the array = iSize = %llu\n", iSize);
    
    
      // image corners in world coordinate
      // center and radius
      // center and zoom
      // GradientRepetition
      printf ("Maximal number of iterations = iterMax = %d \n", IterMax);
      printf ("ratio of image  = %f ; it should be 1.000 ...\n", ratio);
      
      
      
      printf ("pixel counters\n");
      printf ("uUnknown = %llu\n", uUnknown);
      printf ("uExterior = %llu\n", uExterior);
      printf ("uInterior3 = %llu\n", uInterior3);
      printf ("uInterior105 = %llu\n", uInterior105);
      printf ("Sum of pixels  = %llu\n", uInterior3 + uInterior105 + uExterior + uUnknown);
      printf ("all pixels of the array = iSize = %llu\n", iSize);
      printf ("Maximum value for an unsigned long long int = ULLONG_MAX = %llu\n",
    	  ULLONG_MAX);
    
      //
    
    
    
    
      return 0;
    }
    
    
    
    
    
    
    // *****************************************************************************
    //;;;;;;;;;;;;;;;;;;;;;;  setup ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    // **************************************************************************************
    
    int
    setup ()
    {
    
      fprintf (stdout, "setup start\n");
    
    
    
    
    
    
      /* 2D array ranges */
    
      iWidth = iHeight;
      iSize = iWidth * iHeight;	// size = number of points in array 
      // iy
      iyMax = iHeight - 1;		// Indexes of array starts from 0 not 1 so the highest elements of an array is = array_name[size-1].
      //ix
    
      ixMax = iWidth - 1;
    
      /* 1D array ranges */
      // i1Dsize = i2Dsize; // 1D array with the same size as 2D array
      iMax = iSize - 1;		// Indexes of array starts from 0 not 1 so the highest elements of an array is = array_name[size-1].
    
      /* Pixel sizes */
      PixelWidth = (ZxMax - ZxMin) / ixMax;	//  ixMax = (iWidth-1)  step between pixels in world coordinate 
      PixelHeight = (ZyMax - ZyMin) / iyMax;
      ratio = ((ZxMax - ZxMin) / (ZyMax - ZyMin)) / ((double) iWidth / (double) iHeight);	// it should be 1.000 ...
    
      // minimal radius of circla containing all the Julia set
      ER = 2.0; 
      ER2 = ER*ER;
      
      // radius of maximal circle which is inside component
      AR_3 = 7.0*pow (10, -ARe_3);
      AR2_3 = AR_3*AR_3;
      
      AR_105 = 2.5*pow (10, -ARe_105); // adjust the radius : 
      AR2_105 = AR_105*AR_105;
    
    
      /* create dynamic 1D arrays for colors ( shades of gray ) */
      data = malloc (iSize * sizeof (unsigned char));
    
    
      if (data == NULL)
        {
          fprintf (stderr, " Could not allocate memory");
          return 1;
        }
    
    
    
    
    
     
    
    
      fprintf (stdout, " end of setup \n");
    
      return 0;
    
    }				// ;;;;;;;;;;;;;;;;;;;;;;;;; end of the setup ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    
    
    
    int
    end ()
    {
    
    
      fprintf (stdout, " allways free memory (deallocate )  to avoid memory leaks \n");	// https://en.wikipedia.org/wiki/C_dynamic_memory_allocation
      free (data);
    
    
      PrintProgramInfo ();
      PrintCInfo ();
      return 0;
    
    }
    
    // ********************************************************************************************************************
    /* -----------------------------------------  main   -------------------------------------------------------------*/
    // ********************************************************************************************************************
    
    int
    main ()
    {
      setup ();
    
    
      DrawFatouImage (data, IterMax);	// first find Fatou
      SaveArray2PGMFile (data, iWidth, IterMax, ARe_3, ARe_105, 1,"name = iWidth_IterMax_ARe_ ARe_3_ARe_105_1");
      
      MarkTraps(data );
      SaveArray2PGMFile (data, iWidth, IterMax, ARe_3,  ARe_105,2,"name = iWidth_IterMax+1_ARe ARe_3_ARe_105_1");
    
      MarkAttractors(data);
      SaveArray2PGMFile (data, iWidth, IterMax, ARe_3,  ARe_105,3,"name = iWidth_IterMax+1_ARe ARe_3_ARe_105_1");
      
      end ();
    
      return 0;
    }
    

    text output

    OPENMP DISPLAY ENVIRONMENT BEGIN
      _OPENMP = '201511'
      OMP_DYNAMIC = 'FALSE'
      OMP_NESTED = 'FALSE'
      OMP_NUM_THREADS = '8'
      OMP_SCHEDULE = 'DYNAMIC'
      OMP_PROC_BIND = 'FALSE'
      OMP_PLACES = ''
      OMP_STACKSIZE = '0'
      OMP_WAIT_POLICY = 'PASSIVE'
      OMP_THREAD_LIMIT = '4294967295'
      OMP_MAX_ACTIVE_LEVELS = '2147483647'
      OMP_CANCELLATION = 'FALSE'
      OMP_DEFAULT_DEVICE = '0'
      OMP_MAX_TASK_PRIORITY = '0'
      OMP_DISPLAY_AFFINITY = 'FALSE'
      OMP_AFFINITY_FORMAT = 'level %L thread %i affinity %A'
    OPENMP DISPLAY ENVIRONMENT END
    
    File 15000_100000_2_2_2.pgm saved . Comment = name = iWidth_IterMax+1_ARe ARe_3_ARe_105_1	 f(z) = z^6+A*z+c where A= 15000.0000000000000000 ; -0.9240951240062714 	 c =2.0000000000000000 ; 0.0000000000000000 
    mark attractors 
    File 15000_100000_2_2_3.pgm saved . Comment = name = iWidth_IterMax+1_ARe ARe_3_ARe_105_1	 f(z) = z^6+A*z+c where A= 15000.0000000000000000 ; -0.9240951240062714 	 c =2.0000000000000000 ; 0.0000000000000000 
     allways free memory (deallocate )  to avoid memory leaks 
    Numerical approximation of Julia set for fc(z)= z^3+A*z+c 
    parameter c = ( -0.1772460937500000 ; -0.1147460937500000 ) 
    parameter A = ( -0.5168644785881042 ; -0.9240951240062714 ) 
    Image Width = 3.000000 in world coordinate
    PixelWidth = 0.0002000133342223 
    AR_3 = 0.0700000000000000 
    ER = 2.0000000000000000 
    Maximal number of iterations = iterMax = 100000 
    ratio of image  = 1.000000 ; it should be 1.000 ...
    pixel counters
    uUnknown = 0
    uExterior = 138102480
    uInterior3 = 12516176
    uInterior105 = 12668216
    Sum of pixels  = 163286872
    all pixels of the array = iSize = 225000000
    Maximum value for an unsigned long long int = ULLONG_MAX = 18446744073709551615
    gcc version: 9.3.0
    __STDC__ = 1
    __STDC_VERSION__ = 201710
    c dialect = C18
    
    real	2m5,118s
    user	16m11,754s
    sys	0m0,918s
    
    

    References

    1. ↑ fractalforums.org : julia-sets-true-shape-and-escape-time

    Captions

    Cubic Julia set z^3+A*z+c with two cycles of length 3 and 105. c=(-5947392-3850240*i) * 2^-25 A=(-17343094-31007487*i) * 2^-25

    Items portrayed in this file

    depicts

    12 July 2020

    image/png

    348b3fef0243871fa758be7a41f9f5a132736e85

    571,901 byte

    2,000 pixel

    2,000 pixel

    File history

    Click on a date/time to view the file as it appeared at that time.

    Date/TimeThumbnailDimensionsUserComment
    current17:25, 12 July 2020Thumbnail for version as of 17:25, 12 July 20202,000 × 2,000 (558 KB)wikimediacommons>Soul windsurferbetter exif notes inside file

    There are no pages that use this file.